<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding: 0;
            margin: 0;
            list-style: none;
            border: none;
            text-decoration: none;
        }
        a{
            color: black;
        }
        #nav{
            width:909px ;
            height: 49px;
            border: #cccccc 1px solid;
            margin: 100px auto;
            overflow: hidden;
        }
        #nav ul{
            width: 100%;
        }
        #ul li{
            float: left;
            text-align: center;
            line-height: 49px;
            width: 100px;
            border-right: 1px dashed #ccc;
            background: url("images/_r1_c1.png") no-repeat 0 0 ;
            position: relative;
        }
        #nav ul li a{
            width: 100%;
            height: 100%;
            display: inline-block;
        }
        #nav ul li span{
            position:absolute ;
            width: 100px;
            height: 49px;
            background: skyblue;
            top: 49px;
            left: 0;
            z-index: -1;
        }
    </style>

</head>
<body>
<nav id="nav">
    <ul id="ul">
        <li><a href="">首页</a><span></span><audio src="source/a1.mp3"></audio></li>
        <li><a href="">新头条</a><span></span><audio src="source/a2.mp3"></audio></li>
        <li><a href="">电视剧</a><span></span><audio src="source/a3.mp3"></audio></li>
        <li><a href="">新电影</a><span></span><audio src="source/a4.mp3"></audio></li>
        <li><a href="">小游戏</a><span></span><audio src="source/a5.mp3"></audio></li>
        <li><a href="">小说汇</a><span></span><audio src="source/a6.mp3"></audio></li>
        <li><a href="">旅游假</a><span></span><audio src="source/a7.mp3"></audio></li>
        <li><a href="">正品购</a><span></span><audio src="source/a8.mp3"></audio></li>
        <li><a href="">今日团</a><span></span><audio src="source/a9.mp3"></audio></li>
    </ul>
</nav>
<script src="js/myFunc.js"></script>
<script>
    window.onload = function () {
        var ul = document.getElementById("ul");
        var allLis = ul.children;
        for(var i=0; i<allLis.length; i++) {
            allLis[i].style.backgroundPosition = '0 ' + i * -40 + 'px';
            var li = allLis[i];
            li.onmouseover = function () {
                buffer(this.children[1],{"top":0});
                this.children[2].play();
                this.children[2].currentTime = 0;
            };
            li.onmouseout = function () {
                buffer(this.children[1],{"top":49});
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event
            var code = e.keyCode -49;
            buffer(allLis[code].children[1],{"top":0},function () {
                buffer(allLis[code].children[1],{"top":49});
            });
            allLis[code].children[2].play();
            allLis[code].children[2].currentTime = 0;
        }
    }
</script>
</body>
</html>